from enum import Enum,unique

from enum import IntEnum    #继承该类强制必须使用数字

#保障值唯一，禁止取别名，否则报错
@unique
class VIP(Enum):
    yellow = 1
    green = 2
    black = 3
    red = 4

#好处
#不可变
#变量名和值不能重复
print(type(VIP.yellow))
print(type(VIP.yellow.name))
print(VIP.yellow,VIP.yellow.value)

#遍历
for v in VIP:
    print(v)

print(VIP.yellow == 1)
print(VIP.yellow.__eq__(1))
#不能进行大小比较


#普通变量变枚举类型
a = 1
print(VIP.yellow == VIP(a))
print(VIP.yellow == a)